package c.e.a.b.f.b;

import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import c.e.a.b.b.j.c;
import java.util.Objects;

/* compiled from: com.google.android.gms:play-services-measurement-impl@@18.0.0 */
public final class q3 extends r5 {
    public char c = 0;
    public long d = -1;
    public String e;
    public final s3 f = new s3(this, 6, false, false);
    public final s3 g = new s3(this, 6, true, false);
    public final s3 h = new s3(this, 6, false, true);
    public final s3 i = new s3(this, 5, false, false);
    public final s3 j = new s3(this, 5, true, false);
    public final s3 k = new s3(this, 5, false, true);
    public final s3 l = new s3(this, 4, false, false);
    public final s3 m = new s3(this, 3, false, false);
    public final s3 n = new s3(this, 2, false, false);

    public q3(u4 u4Var) {
        super(u4Var);
    }

    public static Object s(String str) {
        return str == null ? null : new v3(str);
    }

    public static String t(boolean z, Object obj) {
        String str = "";
        if (obj == null) {
            return str;
        }
        if (obj instanceof Integer) {
            obj = Long.valueOf((long) ((Integer) obj).intValue());
        }
        String str2 = "-";
        int i = 0;
        String valueOf;
        if (obj instanceof Long) {
            if (!z) {
                return String.valueOf(obj);
            }
            Long l = (Long) obj;
            if (Math.abs(l.longValue()) < 100) {
                return String.valueOf(obj);
            }
            if (String.valueOf(obj).charAt(0) == '-') {
                str = str2;
            }
            valueOf = String.valueOf(Math.abs(l.longValue()));
            long round = Math.round(Math.pow(10.0d, (double) (valueOf.length() - 1)));
            long round2 = Math.round(Math.pow(10.0d, (double) valueOf.length()) - 1.0d);
            StringBuilder stringBuilder = new StringBuilder(str.length() + (str.length() + 43));
            stringBuilder.append(str);
            stringBuilder.append(round);
            stringBuilder.append("...");
            stringBuilder.append(str);
            stringBuilder.append(round2);
            return stringBuilder.toString();
        } else if (obj instanceof Boolean) {
            return String.valueOf(obj);
        } else {
            if (obj instanceof Throwable) {
                Throwable th = (Throwable) obj;
                StringBuilder stringBuilder2 = new StringBuilder(z ? th.getClass().getName() : th.toString());
                valueOf = y(u4.class.getCanonicalName());
                StackTraceElement[] stackTrace = th.getStackTrace();
                int length = stackTrace.length;
                while (i < length) {
                    StackTraceElement stackTraceElement = stackTrace[i];
                    if (!stackTraceElement.isNativeMethod()) {
                        String className = stackTraceElement.getClassName();
                        if (className != null && y(className).equals(valueOf)) {
                            stringBuilder2.append(": ");
                            stringBuilder2.append(stackTraceElement);
                            break;
                        }
                    }
                    i++;
                }
                return stringBuilder2.toString();
            } else if (obj instanceof v3) {
                return ((v3) obj).a;
            } else {
                if (z) {
                    return str2;
                }
                return String.valueOf(obj);
            }
        }
    }

    public static String u(boolean z, String str, Object obj, Object obj2, Object obj3) {
        CharSequence str2;
        String str3 = "";
        if (str2 == null) {
            str2 = str3;
        }
        String t = t(z, obj);
        String t2 = t(z, obj2);
        String t3 = t(z, obj3);
        StringBuilder stringBuilder = new StringBuilder();
        if (!TextUtils.isEmpty(str2)) {
            stringBuilder.append(str2);
            str3 = ": ";
        }
        String str4 = ", ";
        if (!TextUtils.isEmpty(t)) {
            stringBuilder.append(str3);
            stringBuilder.append(t);
            str3 = str4;
        }
        if (TextUtils.isEmpty(t2)) {
            str4 = str3;
        } else {
            stringBuilder.append(str3);
            stringBuilder.append(t2);
        }
        if (!TextUtils.isEmpty(t3)) {
            stringBuilder.append(str4);
            stringBuilder.append(t3);
        }
        return stringBuilder.toString();
    }

    public static String y(String str) {
        if (TextUtils.isEmpty(str)) {
            return "";
        }
        int lastIndexOf = str.lastIndexOf(46);
        if (lastIndexOf == -1) {
            return str;
        }
        return str.substring(0, lastIndexOf);
    }

    public final s3 A() {
        return this.i;
    }

    public final s3 B() {
        return this.k;
    }

    public final s3 C() {
        return this.m;
    }

    public final s3 D() {
        return this.n;
    }

    public final String E() {
        Pair pair;
        k4 k4Var = l().d;
        k4Var.e.g();
        k4Var.e.g();
        long j = k4Var.e.w().getLong(k4Var.a, 0);
        if (j == 0) {
            k4Var.a();
            j = 0;
        } else {
            Objects.requireNonNull((c) k4Var.e.a.n);
            j = Math.abs(j - System.currentTimeMillis());
        }
        long j2 = k4Var.d;
        if (j >= j2) {
            if (j > (j2 << 1)) {
                k4Var.a();
            } else {
                String string = k4Var.e.w().getString(k4Var.c, null);
                j2 = k4Var.e.w().getLong(k4Var.b, 0);
                k4Var.a();
                if (string == null || j2 <= 0) {
                    pair = d4.D;
                } else {
                    pair = new Pair(string, Long.valueOf(j2));
                }
                if (pair != null || pair == d4.D) {
                    return null;
                }
                string = String.valueOf(pair.second);
                String str = (String) pair.first;
                StringBuilder stringBuilder = new StringBuilder(String.valueOf(str).length() + (string.length() + 1));
                stringBuilder.append(string);
                stringBuilder.append(":");
                stringBuilder.append(str);
                return stringBuilder.toString();
            }
        }
        pair = null;
        if (pair != null) {
        }
        return null;
    }

    public final String F() {
        String str;
        synchronized (this) {
            if (this.e == null) {
                str = this.a.d;
                if (str == null) {
                    str = "FA";
                }
                this.e = str;
            }
            str = this.e;
        }
        return str;
    }

    public final boolean r() {
        return false;
    }

    public final void v(int i, String str) {
        Log.println(i, F(), str);
    }

    public final void w(int i, boolean z, boolean z2, String str, Object obj, Object obj2, Object obj3) {
        if (!z && Log.isLoggable(F(), i)) {
            Log.println(i, F(), u(false, str, obj, obj2, obj3));
        }
        if (!z2 && i >= 5) {
            Objects.requireNonNull(str, "null reference");
            r4 r4Var = this.a.j;
            if (r4Var == null) {
                v(6, "Scheduler not set. Not logging error/warn");
            } else if (r4Var.n()) {
                if (i < 0) {
                    i = 0;
                }
                r4Var.v(new t3(this, i >= 9 ? 8 : i, str, obj, obj2, obj3));
            } else {
                v(6, "Scheduler not initialized. Not logging error/warn");
            }
        }
    }

    public final boolean x(int i) {
        return Log.isLoggable(F(), i);
    }

    public final s3 z() {
        return this.f;
    }
}
